<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
  <script>
      window.onload = function(){
           var input_element = document.getElementsByTagName("input");
           input_element[3].onclick=function(){
            var nian = parseFloat(input_element[0].value);
            var yue =  parseFloat(input_element[1].value);
            switch(yue){
                case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:input_element[2].value = 31;break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:input_element[2].value = 30;break;
                    case 2:
                        if(nian%4 == 0&&nian%100 !=0||nian%400==0){
                            input_element[2].value = 29;
                        }else{
                            input_element[2].value = 28;
                        }

            }
           
           }
          input_element[4].onclick=function(){
            input_element[0].value = "";
            input_element[1].value = "";
            input_element[2].value = "";
           
        }
      }
  </script>
<body>
    <h1>请输入年和月，求当年当月有多少天</h1>
    <form action="">
        <input type="text" name="" id="" placeholder="请输入年"> 年
        <input type="text" name="" id="" placeholder="请输入月">月有
        <input type="text" name="" id="" placeholder="点击确定求结果">天
        <input type="button" value="确定">
        <input type="button" value="重置">
    </form>
</body>
</html>